<template>
    <div class="news-list">
        <NuxtLink class="news-item" :to="`/news/${item.id}.html`" target="_blank" v-for="item in props.list" :key="item">
            <div class="news-item__left">
                <div class="news-item__date">
                    <p class="date">
                        {{ formatDate(item.createtime, "DD") }}
                    </p>
                    <p class="year">
                        {{ formatDate(item.createtime, "YYYY.MM") }}
                    </p>
                </div>

                <div class="news-item__line">
                    <div class="bg"></div>
                </div>
            </div>
            <div class="news-item__right">
                <div class="news-item__title" :title="item.title">
                    {{ item.title }}
                </div>
                <div class="news-item__desc" :title="item.subtitle">
                    {{ item.subtitle }}
                </div>
            </div>

            <img class="cover-image" :src="item.cover_image ? item.cover_image + '?x-oss-process=image/format,webp' :
                'https://yzpt-resources.oss-cn-hangzhou.aliyuncs.com/web/images/home/home-swiper-1.jpg?x-oss-process=image/watermark,image_d2F0ZXIvd2F0ZXJtYXJrLnBuZw'
                " />
        </NuxtLink>
    </div>
</template>
<script setup>
const props = defineProps({
    list: {
        type: Array,
        default: () => [],
    },
});
</script>
<style lang="scss" scoped>
.news-list {
    display: flex;
    flex-wrap: wrap;

    .news-item {
        position: relative;
        display: flex;
        width: 580px;
        height: 240px;
        padding: 30px 30px 0 40px;
        border-radius: 4px;
        box-shadow: 0px 0px 10px 0px rgba(1, 23, 86, 0.1);
        margin-top: 30px;
        margin-right: 40px;
        border: 1px solid transparent;
        background-color: #fff;
        cursor: pointer;
        text-decoration: none;

        .cover-image {
            width: 425px;
            height: 100%;
            position: absolute;
            right: 0;
            top: 0;
            object-fit: cover;
            opacity: 0;
            transition: all 0.4s;
        }

        &:nth-of-type(1),
        &:nth-of-type(2) {
            margin-top: 0;
        }

        &:nth-of-type(2n) {
            margin-right: 0;
        }

        &:hover {
            border-color: #5085fb;

            .news-item__title {
                color: #5085fb;
            }

            .news-item__line {
                .bg {
                    width: 2px;
                    margin-left: -0.5px;
                    height: 100%;
                }
            }

            .cover-image {
                opacity: 1;
            }

            .news-item__date {

                .date,
                .year {
                    color: #5085fb;
                }
            }
        }

        &__left {
            margin-right: 47px;
            width: 70px;
            flex-shrink: 0;
        }

        &__date {
            text-align: center;
            font-family: "DINCond_Regular";

            .date {
                color: #333;
                font-weight: bold;
                line-height: 1;
                font-size: 62px;
                transition: all 0.4s;
            }

            .year {
                font-size: 20px;
                color: #999;
                margin-top: 6px;
                transition: all 0.4s;
            }
        }

        &__line {
            width: 1px;
            height: 80px;
            background-color: #ddd;
            margin: 10px auto 0;

            .bg {
                width: 100%;
                height: 0%;
                background-color: #5085fb;
                transition: height 0.4s linear;
            }
        }

        &__right {
            margin-top: 10px;
        }

        &__title {
            width: 350px;
            height: 45px;
            line-height: 22.5px;
            font-size: 16px;
            color: #111;
            margin-bottom: 28px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        &__desc {
            line-height: 26px;
            color: #666;
            display: -webkit-box;
            overflow: hidden;
            text-overflow: ellipsis;
            -webkit-line-clamp: 3;
            -webkit-box-orient: vertical;
        }
    }
}
</style>
